//
//  WiFiReceiveDataManager.m
//  SmartYunYiWindow
//
//  Created by JianWei Chen on 17/4/10.
//  Copyright © 2017年 JianWei Chen. All rights reserved.
//

#import "WiFiReceiveDataManager.h"
#import "DataBackBaseModel.h"
#import "DataDeviceStatusModel.h"

@implementation WiFiReceiveDataManager

+ (WiFiReceiveDataManager *)defaultService
{
    static WiFiReceiveDataManager *static_manager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        static_manager = [[WiFiReceiveDataManager alloc]init];
    });
    return static_manager;
}

- (void)handleTheBackData:(NSString *)backDataString andBackCode:(NSString *)codeString mac:(NSString *)macAddress
{
    DataBackBaseModel *baseModel = nil;
    switch (strtoul([codeString UTF8String], 0, 16)) {
        case DeviceToAppAddFingerprintOrCardState:
        {
            if ([backDataString isEqualToString:@"01"])
            {
                [[NSNotificationCenter defaultCenter]postNotificationName:AddFingerprintOrCardStateNotification object:@{}];
            }
            else if ([backDataString isEqualToString:@"02"])
            {
                [SVProgressHUD showErrorWithStatus:@"存量已满"];
            }
            else
            {
                [SVProgressHUD showErrorWithStatus:@"操作错误"];
            }
        }
             break;
        case DeviceToAppAddFingerprintOrCardSuccess:
        {
            [[NSNotificationCenter defaultCenter]postNotificationName:AddFingerprintOrCardSuccessNotification object:@{}];

        }
            break;
        case DeviceToAppDeleteFingerprintOrCardOrPassword:
        {
            [[NSNotificationCenter defaultCenter]postNotificationName:DeleteFingerprintOrCardOrPasswordNotification object:backDataString];

        }
            break;
        case DeviceToAppRestoreFactorySetting:
        {
            [[NSNotificationCenter defaultCenter]postNotificationName:RestoreFactorySettingNotification object:@{}];

        }
            break;
        case DeviceToAppRemoteUnlocking:
        {
            [[NSNotificationCenter defaultCenter]postNotificationName:AddFingerprintOrCardStateNotification object:backDataString];

        }
            break;
        case DeviceToAppUnlockingModelSetting:
        {
            [[NSNotificationCenter defaultCenter]postNotificationName:AddFingerprintOrCardStateNotification object:backDataString];

        }
            break;
        default:
        {
            NSLog(@"其他指令进来了");
        }
            break;
    }
    if (baseModel == nil) {
        return;
    }
    //            baseModel = [[DataDeviceStatusModel alloc]initWithFunctionCode:codeString data:backDataString mac:macAddress];
//    [[NSNotificationCenter defaultCenter]postNotificationName:NOTIFY_DEVICE_DATA_BACK object:baseModel];
}

@end
